#ifndef __THREADPOOL_H__
#define __THREADPOOL_H__

#include "TaskQueue.h"
#include "Thread.h"

#include <memory>
using std::shared_ptr;

#include <vector>
using std::vector;

#include <functional>
using std::function;

namespace tp
{
class ThreadPool
{
    typedef function<void()> Func;
public:
    ThreadPool(size_t queSize, size_t threadNum);
    ~ThreadPool();

    void start();
    void stop();
    void addTask(const Func&);

private:
    void doTask();

private:
    size_t _queSize;
    size_t _threadNum;
    TaskQueue _que;
    vector<shared_ptr<Thread>> _threads;
    bool _isExit;
};
}

#endif
